package code;
import java.security.Key;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class SymmetricKeyMaker {
	public String algorithm=null; //DES, Blowfish, AES
	private SecretKey key=null;
	public Integer size=null;
	
	
	public SymmetricKeyMaker(String algorithm, Integer size){
		this.algorithm=algorithm;
		this.size=size;//DES key size must be 56, AES key size 128 192 256
	}
	
	public SymmetricKeyMaker(String algorithm){
		this.algorithm=algorithm;
		
	}
	
	public void generateKey(){
		try {
			KeyGenerator keyGen = KeyGenerator.getInstance(algorithm);
			if(size!=null){
			keyGen.init(size);
			}
			key = keyGen.generateKey();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public SecretKey getKey() {
		return key;
		
	}
	public static void main(String args[]){
		SymmetricKeyMaker sym = new SymmetricKeyMaker("Serpent");
		sym.generateKey();
		SymmetricEncDec ed= new SymmetricEncDec();
		ed.encrypt(sym.getKey(), "Serpent", "C:\\Documents and Settings\\Nil Kural\\Desktop\\driving.txt");
	}
 
}
